
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import javax.swing.JOptionPane;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * GuestIDScreen.java
 *
 * Created on Dec 13, 2011, 8:59:46 PM
 */

/**
 *
 * @author dabeast23
 */
public class WakeUpCall extends javax.swing.JFrame {

    /** Creates new form GuestIDScreen */
    public WakeUpCall() {
        setResizable(false);
	setTitle("Hotel Kiosk: Wake-Up Call");
	setDefaultCloseOperation(this.EXIT_ON_CLOSE);
        initComponents();
        this.setLocationRelativeTo(null);
        
    }
    
    public WakeUpCall(ArrayList<Reservation> reservationList, Reservation currentGuest) {
        setResizable(false);
	setTitle("Hotel Kiosk: Wake-Up Call");
	setDefaultCloseOperation(this.EXIT_ON_CLOSE);
        this.reservationList = reservationList;
        this.currentGuest = currentGuest;
        initComponents();
        
        this.setLocationRelativeTo(null);
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        backgroundPanel = new javax.swing.JPanel();
        setTimeButton = new javax.swing.JButton();
        guestIDPromptLabel = new javax.swing.JLabel();
        backButton = new javax.swing.JButton();
        amPMComboBox = new javax.swing.JComboBox();
        hourComboBox = new javax.swing.JComboBox();
        minuteComboBox = new javax.swing.JComboBox();
        wakeUpCallLabel = new javax.swing.JLabel();
        cancelWakeUpCallButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        backgroundPanel.setBackground(new java.awt.Color(102, 0, 0));
        backgroundPanel.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        setTimeButton.setBackground(new java.awt.Color(255, 255, 204));
        setTimeButton.setFont(new java.awt.Font("Comic Sans MS", 0, 18)); // NOI18N
        setTimeButton.setForeground(new java.awt.Color(102, 0, 0));
        setTimeButton.setBorder(null);
        setTimeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                setTimeButtonActionPerformed(evt);
            }
        });
        backgroundPanel.add(setTimeButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 190, 171, 33));
        setTimeButton.setText("Set Time");

        guestIDPromptLabel.setFont(new java.awt.Font("Tahoma", 1, 24));
        guestIDPromptLabel.setForeground(new java.awt.Color(255, 255, 204));
        guestIDPromptLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        guestIDPromptLabel.setText(":");
        backgroundPanel.add(guestIDPromptLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 130, 10, 20));

        backButton.setBackground(new java.awt.Color(255, 255, 204));
        backButton.setFont(new java.awt.Font("Comic Sans MS", 0, 11));
        backButton.setForeground(new java.awt.Color(255, 255, 255));
        backButton.setText("Back");
        backButton.setContentAreaFilled(false);
        backButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backButtonActionPerformed(evt);
            }
        });
        backgroundPanel.add(backButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(338, 271, -1, -1));

        amPMComboBox.setFont(new java.awt.Font("Tahoma", 1, 14));
        amPMComboBox.setMaximumRowCount(2);
        amPMComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "A.M.", "P.M." }));
        backgroundPanel.add(amPMComboBox, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 130, 60, 30));
        if(currentGuest.isWakeUpCallSet()==true)
        {
            amPMComboBox.setSelectedIndex(currentGuest.getWakeUpAMPM());
        }

        hourComboBox.setFont(new java.awt.Font("Tahoma", 1, 14));
        hourComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" }));
        hourComboBox.setSelectedItem(null);
        backgroundPanel.add(hourComboBox, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 130, -1, 30));
        if(currentGuest.isWakeUpCallSet()==true)
        {
            hourComboBox.setSelectedIndex(currentGuest.getWakeUpHour()-1);
        }

        minuteComboBox.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        minuteComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59" }));
        minuteComboBox.setSelectedItem(null);
        backgroundPanel.add(minuteComboBox, new org.netbeans.lib.awtextra.AbsoluteConstraints(170, 130, 50, 30));
        if(currentGuest.isWakeUpCallSet()==true)
        {
            minuteComboBox.setSelectedIndex(currentGuest.getWakeUpMinute()-1);
        }

        wakeUpCallLabel.setFont(new java.awt.Font("Tahoma", 1, 24));
        wakeUpCallLabel.setForeground(new java.awt.Color(255, 255, 204));
        wakeUpCallLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        wakeUpCallLabel.setText("Set Time for Wake-Up Call");
        backgroundPanel.add(wakeUpCallLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 40, 330, 50));

        cancelWakeUpCallButton.setBackground(new java.awt.Color(255, 255, 204));
        cancelWakeUpCallButton.setFont(new java.awt.Font("Comic Sans MS", 0, 18)); // NOI18N
        cancelWakeUpCallButton.setForeground(new java.awt.Color(102, 0, 0));
        cancelWakeUpCallButton.setText("Cancel Wake Up Call");
        cancelWakeUpCallButton.setBorder(null);
        cancelWakeUpCallButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelWakeUpCallButtonActionPerformed(evt);
            }
        });
        backgroundPanel.add(cancelWakeUpCallButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 240, 171, 33));
        cancelWakeUpCallButton.setVisible(false);
        if(currentGuest.isWakeUpCallSet()==true)
        cancelWakeUpCallButton.setVisible(true);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(backgroundPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 405, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(backgroundPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 307, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void setTimeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_setTimeButtonActionPerformed

        if(hourComboBox.getSelectedIndex()==-1 || minuteComboBox.getSelectedIndex()==-1)
        {
            JOptionPane.showMessageDialog(this,
    "Please select both the hour and minutes!","Not a valid time!",JOptionPane.ERROR_MESSAGE);
        }
        else
        {
            String hour = (String)hourComboBox.getSelectedItem();
            String minute = (String)minuteComboBox.getSelectedItem();
            String amPMString = (String)amPMComboBox.getSelectedItem();
        int n = JOptionPane.showConfirmDialog(this,
            "Are you sure you want to set your wake up call for "+hour+":"+minute+amPMString+"?",
            "Confirm Wake Up Call", JOptionPane.YES_NO_OPTION);
        
        if(n==0)
        {
            

            
            int hourNum = Integer.parseInt(hour);
            int minuteNum = Integer.parseInt(minute);
            int amPM = amPMComboBox.getSelectedIndex();

            currentGuest.setWakeUpCallSet(true);
            JOptionPane.showMessageDialog(this,
    "Your wake up call is set to " +hour+":"+minute+amPMString);

            currentGuest.setWakeUpHour(hourNum);
            currentGuest.setWakeUpMinute(minuteNum);
            currentGuest.setWakeUpAMPM(amPM);
            currentGuest.setWakeUpMinuteString(minute);
            currentGuest.setWakeUpAMPMString(amPMString);

            System.out.println(hourNum);
            System.out.println(minuteNum);

            CurrentGuest CG = new CurrentGuest(reservationList,currentGuest);
            CG.setVisible(true);
            this.setVisible(false);

        }
        //System.out.println(n);
        }
}//GEN-LAST:event_setTimeButtonActionPerformed

    private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backButtonActionPerformed
        CurrentGuest CG = new CurrentGuest(reservationList,currentGuest);
        CG.setVisible(true);
        this.setVisible(false);
}//GEN-LAST:event_backButtonActionPerformed

    private void cancelWakeUpCallButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelWakeUpCallButtonActionPerformed
        // TODO add your handling code here:
        int n = JOptionPane.showConfirmDialog(this,
            "Are you sure you want to cancel your wake up call?",
            "Cancel Wake Up Call", JOptionPane.YES_NO_OPTION);

        if(n==0)
        {
            currentGuest.setWakeUpCallSet(false);
            CurrentGuest CG = new CurrentGuest(reservationList,currentGuest);
            CG.setVisible(true);
            this.setVisible(false);

        }
    }//GEN-LAST:event_cancelWakeUpCallButtonActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new GuestIDScreen().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox amPMComboBox;
    private javax.swing.JButton backButton;
    private javax.swing.JPanel backgroundPanel;
    private javax.swing.JButton cancelWakeUpCallButton;
    private javax.swing.JLabel guestIDPromptLabel;
    private javax.swing.JComboBox hourComboBox;
    private javax.swing.JComboBox minuteComboBox;
    private javax.swing.JButton setTimeButton;
    private javax.swing.JLabel wakeUpCallLabel;
    // End of variables declaration//GEN-END:variables
    public ArrayList<String> userIDs = new ArrayList();
    private ArrayList <Reservation> reservationList;
    Reservation currentGuest;
   

    
}
